package com.team.order.controller;

import com.team.common.core.web.domain.AjaxResult;
import com.team.order.domain.vo.RegionOrderStatisticsVO;
import com.team.order.service.OrderStatisticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/order/statistics")
@RequiredArgsConstructor
public class OrderStatisticsController {

    private final OrderStatisticsService orderStatisticsService;

    @GetMapping("/region")
    public AjaxResult getOrderStatisticsByRegion(@RequestParam(required = false) String startTime,
                                                @RequestParam(required = false) String endTime) {
        List<RegionOrderStatisticsVO> result = orderStatisticsService.getOrderStatsByRegion(startTime, endTime);
        return AjaxResult.success(result);
    }
}
